package lte

import (
	"math"
	"math/cmplx"
)

type PSS struct {
	ID   int
	ofd  []complex128
	fd   []complex128
	tlen int
	td   []complex128
}

func (p *PSS) Fd() []complex128  { return p.fd }
func (p *PSS) Ofd() []complex128 { return p.ofd }
func (p *PSS) Td() []complex128  { return p.td }

func NewPSS(t int) *PSS {
	_ofd := make([]complex128, 63)
	c := complex(0.0, -math.Pi*float64(ZC_MAP[t])/63.0)
	for i := 0; i < 63; i++ {
		ii := i * (i + 1)
		_ofd[i] = cmplx.Exp(c * complex(float64(ii), 0.0))
	}
	ofd := make([]complex128, 62)
	copy(ofd[:31], _ofd[:31])
	copy(ofd[31:], _ofd[32:])
	fd := make([]complex128, 128)
	copy(fd[1:32], _ofd[32:])
	copy(fd[97:], _ofd[:31])
	tx_ifft := tx_ifft_plan[6]
	_td := tx_ifft.Buf
	copy(_td, fd)
	tx_ifft.ExecuteAndScale(1.0 / 128.)
	tlen := 137
	td := make([]complex128, tlen)
	copy(td[9:], _td[:])
	copy(td[:9], _td[len(_td)-9:])
	return &PSS{t, ofd, fd, tlen, td}
}

func (ps *PSS) ChestFD(rfd []complex128) (chf []complex128) {
	return
}
